package com.csu.hemiao.controller;

import com.csu.hemiao.common.CommonResponse;
import com.csu.hemiao.service.UserService;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/user/")
public class UserController {
    @Autowired
    UserService userService;

    //登录
    @GetMapping("login")
    @ResponseBody
    public CommonResponse<JSONObject> login(int account, String password, String inputValidCode) throws JSONException {
        return userService.login(account, password, inputValidCode);
    }

    //查看用户信息
    @GetMapping("checkUserInfo")
    @ResponseBody
    public CommonResponse<JSONObject> checkUserInfo() throws JSONException {
        return userService.checkUserInfo();
    }
}
